package com.stars.empoly.activity

import androidx.fragment.app.Fragment
import com.qmuiteam.qmui.widget.tab.QMUITab
import com.qmuiteam.qmui.widget.tab.QMUITabBuilder
import com.stars.empoly.base.MBTabActivity
import com.stars.empoly.databinding.ActivityPatformBinding
import com.stars.empoly.fragment.IncomeListFragment
import com.stars.empoly.vmodel.PlatformVModel
import com.trailer.base.utils.B

/**
 *
 *on 2021/7/19
 */
class PlatformActivity: MBTabActivity<PlatformVModel, ActivityPatformBinding>() {


    override fun __before() {
        super.__before()
        vm.type=intent?.extras?.getString("type");
    }

    override fun vmClass(): Class<PlatformVModel> {
        return PlatformVModel::class.java
    }
    override fun createTabs(tabBuilder: QMUITabBuilder): Array<QMUITab> {
        val component = tabBuilder
                .setText("全部")
                .build(context())

        val two = tabBuilder
                .setText("已完成")
                .build(context())


        return arrayOf(component,two)
    }

    override fun binding(): ActivityPatformBinding {
        return ActivityPatformBinding.inflate(layoutInflater)
    }

    override fun getPageItem(position: Int): Fragment {

        var ownerFragment = IncomeListFragment()

        when (position) {
            0 -> {
                ownerFragment.arguments = B().putString("type", vm.type)
                        .putString("status","0")
                        .ok()
                return ownerFragment
            }

            1 -> {
                ownerFragment.arguments = B().putString("type", vm.type)
                        .putString("status","1")
                        .ok()
                return ownerFragment

            }


            else->{
                ownerFragment.arguments = B().putString("type", vm.type)
                        .putString("status","0")
                        .ok()
                return ownerFragment
            }

        }
    }

    override fun getPageCount(): Int {
        return 2
    }

    override fun title(): String? {

        if(vm.type.equals("1")){
            return "平台收益"
        }
        return "轿车收益"
    }
}
